package com.linln.modules.system.domain;

import java.io.Serializable;
import java.util.List;

import javax.persistence.Entity;
import javax.persistence.EntityListeners;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Table;
import javax.persistence.Transient;

import org.springframework.data.jpa.domain.support.AuditingEntityListener;

import lombok.Data;

/**
 * @author hct
 * @date 2019/10/02
 */
@Data
@Entity
@Table(name = "sys_area")
@EntityListeners(AuditingEntityListener.class)
public class Area implements Serializable {
	    @Id
	    @GeneratedValue(strategy = GenerationType.IDENTITY)
	    private Long id;
	    
	    
	    private String name;
	    
	    private String code;
	    
	    private Long pid;
	    @Transient
	    private String parentAreaName;
	    
	    private String pids;
	    private Byte type;
	    
	    private Integer sort;
	    
	    private String firstletter;
	    @Transient
	    private List<Area> children;
	    //是否已被代理 0否 1是 默认0
	    private Integer isagent;
	    //代理人信息
	    private Long memberId;
	    
	    private Integer status;
	    
	    private String remark;
	    
	    public Area() { }
	    
	    public Area(Long id, String name, String pids) {
	        this.id = id;
	        this.name = name;
	        this.pids = pids;
	    }
	    
	    public void setPids(String pids) {
	        if (pids.startsWith(",")){
	            pids = pids.substring(1);
	        }
	        this.pids = pids;
	    }
}
